﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ProductManager_GatheringRecords : System.Web.UI.Page
{
    GoShopping.BLL.Orders.OrderBean ordBean = new GoShopping.BLL.Orders.OrderBean();
    GoShopping.BLL.Orders.GatheringRecordsBean grBean = new GoShopping.BLL.Orders.GatheringRecordsBean();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["ID"] != null)
            {
                hidOrderId.Value = Request.QueryString["ID"].ToString();
                InitialPage();
            }
        }
    }

    private void InitialPage()
    {
        GoShopping.Model.Order ord = ordBean.GetOneOrder(Convert.ToInt32(Request.QueryString["ID"]));
        lblReceCode.Text = "无";
        lblOrderCode.Text = ord.OrderCode;
        lblDate.Text = DateTime.Now.ToString();
        lblMoneyState.Text = "未付款";
        lblPayMan.Text = ord.UserName;
        lblTotal.Text = (ord.TotalPrice + ord.PostPrice).ToString();
        txtGetMoneyMan.Text = "";
        txtMoneyType.Text = "";
        txtComment.Text = "";
    }
    protected void btnComplete_Click(object sender, EventArgs e)
    {
        GoShopping.Model.GatheringRecords gr = new GoShopping.Model.GatheringRecords();
        //保存到数据库
        //lblReceCode.Text;
        gr.OrderID = lblOrderCode.Text;
        gr.RecordDate = Convert.ToDateTime(lblDate.Text);
        gr.Status = lblMoneyState.Text;
        gr.UserName = lblPayMan.Text;
        gr.TotalPrice = Convert.ToDecimal(lblTotal.Text);
        gr.RecordPerson = txtGetMoneyMan.Text;
        gr.MoneyType = txtMoneyType.Text;
        gr.Remark = txtComment.Text;
        grBean.Insert(gr);
        //修改订单状态
        ordBean.UpdateOrder(Convert.ToInt32(Request.QueryString["ID"]), GoShopping.Model.Enumerations.OrderStatusType.Success);
        //跳转到Detail
        Response.Redirect("OrderDetail.aspx?ID=" + Request.QueryString["ID"]);
        
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("OrderDetail.aspx?ID=" + hidOrderId.Value);
    }
}
